(HSP3) sample9 [ファイル読み込み版 バーコード・QRコード読み取り].hsp

sample\hspdsc\32bit\(HSP3) sample9 [ファイル読み込み版 バーコード・QRコード読み取り].hsp » Plain Format

#include "hspbar.as"

	title "ファイルからバーコード読み取りサンプル"
	dialog "jpg;*.gif;*.bmp",16
	if stat == 0 : end
	
	buffer 2
	picload refstr
	mref vram, 66						// BGR... の順番で積まれている
	x = ginfo_winx						// 幅
	y = ginfo_winy						// 高さ
	stride = -(x * 24 + 31) / 32 * 4	// Stride (24bit RGB)
	gsel 0, 1
	
	// 初期化
	bar_Init 1, 1, BarcodeFormat_Default	// JANコードとQRコードに対応
	nIndex = stat
	
	// 結果格納用変数
	size = bar_GetSize()
	sdim res, size
	
	// 読み込み
	bar_Read nIndex, ImageFormat_BGR, vram, x, y, stride, res
	if ( stat < 0 ) {
		dialog "読み込みエラー"
		bar_UnInit nIndex
		end
	} else : if ( stat == 0 ) {
		dialog "画像内にバーコードが見つかりませんでした。"
		bar_UnInit nIndex
		end
	}
	
	// テキスト取得
	bar_GetTextA res
	dupptr txt, stat, 1024, 2
	
	mes txt
	
	// 解放
	bar_Free res
	bar_UnInit nIndex